<html>
<head>
 <title>n3n edge management</title>
</head>
<body>
 <table>
    <tr>
        <td>Last Updated:
        <td><div id="time"></div>
        <td><button onclick=refresh_job()>update</button>
        <td><button onclick=do_stop()>stop edge</button>
    <tr>
        <td>Logging Verbosity:
        <td>
            <div id="verbose"></div>
        <td>
            <button onclick=setverbose(verbose+1)>+</button>
            <button onclick=setverbose(verbose-1)>-</button>
 </table>
 <br>
 <div id="communities"></div>
 <br>
 Edges/Peers:
 <div id="edges"></div>
 <br>
 Supernodes:
 <div id="supernodes"></div>
 <br>
 <div id="timestamps"></div>
 <br>
 <div id="packetstats"></div>

 <script src="script.js"></script>
 <script>
// FIXME: hacky global
var url="/v1";

function refresh_job() {
    do_jsonrpc(
        url, "get_verbose", null,
        'verbose',
        result2verbose, null
    );
    do_jsonrpc(
        url, "get_communities", null,
        'communities',
        rows2keyvalue, ['community']
    );
    do_jsonrpc(
        url, "get_supernodes", null,
        'supernodes',
        rows2table, ['version','current','macaddr','sockaddr','uptime']
    );
    do_jsonrpc(
        url, "get_edges", null,
        'edges',
        rows2table, ['mode','ip4addr','macaddr','sockaddr','desc']
    );
    do_jsonrpc(
        url, "get_timestamps", null,
        'timestamps',
        rows2keyvalueall, null
    );
    do_jsonrpc(
        url, "get_packetstats", null,
        'packetstats',
        rows2table, ['type','tx_pkt','rx_pkt']
    );
    let div = document.getElementById(time);
    time.innerHTML=Date.now()
}

refresh_setup(10000);
refresh_job();
 </script>
</body>
</html>
